package zzzhc.image.model;

import zzzhc.image.recognize.nn.GaussianSOM;
import zzzhc.image.recognize.nn.NN;
import zzzhc.image.recognize.nn.NNType;
import zzzhc.image.recognize.nn.SigmoidNN;
import zzzhc.image.recognize.nn.TrainResult;
import zzzhc.image.recognize.nn.TrainerSetting;
import zzzhc.image.recognize.nn.WinnerTakeAllSOM;

public class TrainerPanelModel {

	private TrainerSetting trainerSetting = new TrainerSetting();

	private OpPanelModel opPanelModel;

	private NNType nnType = NNType.SIGMOID;

	private NN nn;

	private NNInputTableModel nnInputTableModel = new NNInputTableModel();

	private NNTableModel nnTableModel = new NNTableModel();

	private TrainResult trainResult;

	public TrainResult getTrainResult() {
		return trainResult;
	}

	public void setTrainResult(TrainResult trainResult) {
		this.trainResult = trainResult;
		nnTableModel.addColumns(trainResult.getNnOutput());
	}

	public NNInputTableModel getNnInputTableModel() {
		return nnInputTableModel;
	}

	public NNTableModel getNnTableModel() {
		return nnTableModel;
	}

	public void setNnTableModel(NNTableModel nnTableModel) {
		this.nnTableModel = nnTableModel;
	}

	public OpPanelModel getOpPanelModel() {
		return opPanelModel;
	}

	public void setOpPanelModel(OpPanelModel model) {
		this.opPanelModel = model;
	}

	public TrainerSetting getTrainerSetting() {
		return trainerSetting;
	}

	public NN getNN() {
		if (nn == null) {
			if (nnType == NNType.SIGMOID) {
				nn = new SigmoidNN();
			} else if (nnType == NNType.GAUSSIAN) {
				nn = new GaussianSOM();
			} else if (nnType == NNType.WTA) {
				nn = new WinnerTakeAllSOM();
			}
		}
		return nn;
	}

	public void setNnType(NNType nnType) {
		this.nnType = nnType;
	}

	public NNType getNnType() {
		return nnType;
	}

	public void resetNN() {
		nn = null;
	}

}
